package org.jsbd.boss.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IUmAppInfoDao;
import org.jsbd.boss.dao.IUmAppInfoDao;
import org.jsbd.boss.domian.UmAppInfo;
import org.jsbd.boss.domian.UmAppInfo;
import org.jsbd.boss.service.IUmAppInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UmAppInfoServiceImpl implements IUmAppInfoService {

	@Autowired
	private IUmAppInfoDao umAppInfoDao;

	@Override
	public void save(UmAppInfo umAppInfo) {
		umAppInfoDao.save(umAppInfo);
	}

	@Override
	public void save(List<UmAppInfo> list) {
		umAppInfoDao.save(list);
	}

	@Override
	public int update(UmAppInfo umAppInfo) {
		return umAppInfoDao.update(umAppInfo);
	}

	@Override
	public UmAppInfo getById(Integer id) {
		return umAppInfoDao.getById(id);
	}

	@Override
	public List<UmAppInfo> getList(UmAppInfo umAppInfo) {
		return umAppInfoDao.getList(umAppInfo);
	}

	@Override
	public Map<String, Object> getListPage(DataGridModel page, UmAppInfo umAppInfo) {
		umAppInfo = (umAppInfo == null ? new UmAppInfo() : umAppInfo);
		umAppInfo.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", umAppInfoDao.getListPageCount(umAppInfo));

		List<UmAppInfo> list = (List<UmAppInfo>) umAppInfoDao.getList(umAppInfo);
		for (UmAppInfo bk : list) {
			bk.setCreateDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(bk.getCreateTime()));
			bk.setModifyDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(bk.getModifyTime()));
		}
		results.put("rows", list);
		return results;
	}

	@Override
	public void delete(List<Integer> ids) {
		umAppInfoDao.delete(ids);
	}

}
